package ynu.edu.Dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import ynu.edu.Entity.Carbon;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

public interface CarbonDao extends JpaRepository<Carbon,Long> {
    Optional<Carbon> findFirstByOrderByCreateTimeDesc();

    @Query("SELECT c FROM Carbon c WHERE c.createTime >= :oneDayAgo")
    List<Carbon> findByCreateTimeAfter(@Param("oneDayAgo") LocalDateTime oneDayAgo);
}
